package com.hx;

import com.hx.rpc.RpcProxyClinet;
import com.hx.rpc.SpringConfig;
import com.hx.service.IHelloService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {
//        RpcProxyClinet rpcProxyClinet = new RpcProxyClinet();
//        IHelloService iHelloService = rpcProxyClinet
//                .clientProxy(IHelloService.class, "localhost", 8888);
//        String result = iHelloService.sayHello("Hello Huathy..");
//        System.out.println(result);

        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        RpcProxyClinet rpcProxyClinet = context.getBean(RpcProxyClinet.class);
        IHelloService iHelloService = rpcProxyClinet
                .clientProxy(IHelloService.class, "localhost", 8888);
        String result = iHelloService.sayHello("Hello Huathy..");
        System.out.println(result);
    }
}
